class Salasdeaula < ActiveRecord::Base

	validates :predio, :presence => true
	validates :numero, :presence => true, :numericality => { :only_integer => true, :greater_than_or_equal_to => 1 }
	validates :andar, :presence => true, :numericality => { :only_integer => true, :greater_than_or_equal_to => 0 }
	validates :comprimento, :presence => true, :numericality => { :only_float => true, :greater_than_or_equal_to => 1.0 }
	validates :largura, :presence => true, :numericality => { :only_float => true, :greater_than_or_equal_to => 1.0 }
	validates :capacidade, :presence => true, :numericality => { :only_integer => true, :greater_than_or_equal_to => 1 }


	belongs_to :predio
	has_many :atividade, :through => :Salasdeaula, :dependent => :destroy
	has_many :recursos, :through => :recurso_sala, :dependent => :destroy

	def self.numSalaPredio(sala_num, pred_id)
		if !sala_num.blank? and !pred_id.blank?
			find(:first, :conditions => ['predio_id LIKE "%#{pred_id}%" and numero LIKE "%#{sala_num}%"'])			
		end
	end

end
